<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="initial-scale=1, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"/>
  <title>普通分页 - JRoll.Infinite</title>
  <script src="../../download/jroll.min.js"></script>
  <script src="../../download/jroll.infinite.min.js"></script>
  <style>
  html,body {width:100%;height:100%;margin:0;padding:0;overflow:hidden;}
  #wrap {width:100%;height:100%;overflow:hidden;}
  .jroll-infinite-tip {height:32px;line-height:32px;text-align:center;}
  .item {
    line-height: 32px;
    background: #ddd;
    border-bottom: 1px solid #ccc;
    border-top: 1px solid #eee;
    padding-left: 1em;
  }
  </style>
</head>
<body>
  <div id="wrap">
    <div id="scroller"></div>
  </div>
  <script>
  //模拟ajax
  function ajax(parms) {
    var a = [], i;
    var page = parms.url.replace("getData.do?page=", "");
    for (i=1; i<=20; i++) {
      a.push({
        "index":i+(page-1)*20,
        "text":"普通分页加载模式"
      });
    }
    setTimeout(function() {
      parms.success(a);
    }, 200);
  }

  var infinite = new JRoll_Infinite("#wrap", {
    total: 999, //总页数
    getData: function(page, callback) {   //获取数据的函数，必须传递一个数组给callback
      ajax({
        url : "getData.do?page="+page,
        success: function(data) {
          callback(data);
        }
      });
    },
    template: "<div class='item'>{{=_obj.index}}、{{=_obj.text}}</div>" //每条数据模板
  });
  </script>
</body>
</html>